﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="NewRequest.aspx.cs" Inherits="ProjectPayReim.NewRequest" %>

<%@ Register Src="../../Processes/ProcessControl/UserInfo_TY.ascx" TagName="UserInfo"
    TagPrefix="ui" %>
<%@ Register Src="../../Processes/ProcessControl/ApprovalHistory_TY.ascx" TagName="ApprovalHistory"
    TagPrefix="ah" %>
<%@ Register Src="../../Processes/ProcessControl/Attachments_TY.ascx" TagName="Attachments"
    TagPrefix="attach" %>
<%@ Register Src="../../Processes/ProcessControl/ButtonList_TY.ascx" TagName="ButtonList"
    TagPrefix="btn" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>工程设备采购支付及发票报销</title>
    <script src="../../js/jquery.js" type="text/javascript"></script>
    <script type="text/javascript" src="../../js/My97DatePicker/WdatePicker.js"></script>
    <script type="text/javascript" src="../../js/common.js"></script>
    <script type="text/javascript" language="javascript">

        //删除当前行
        function deletetS(rows) {

            $(rows).parent().parent().find("[id*=fld_TCONTRACTNO]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_TSUPPLIERNAME]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_TCONTENTS]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_TCONTRACTPRICE]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_TCONTRACTDATA]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_TSUPPLYDATA]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_YKPJE]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_TPAYMENTPRICE]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_TTHISNEEDPRICE]").attr("class", ".");
            $(rows).parent().parent().find("[id*=fld_TADVANCEDATE]").attr("class", ".");

        }

        function check(ID) {
            if (ID == 'rdoMoney') {
                document.getElementById("DivContract").style.display = "none";
                document.getElementById("mytable").style.display = "";
                document.getElementById("mytable1").style.display = "";
                $("#fld_TTABLETYPE").val("资金支付类");

            } else if (ID == 'rdoRemiber') {

                document.getElementById("mytable").style.display = "none";
                document.getElementById("mytable1").style.display = "none";
                document.getElementById("DivContract").style.display = "";
                $("#fld_TTABLETYPE").val("发票报销类");
            }
        }
        $(document).ready(function () {

            if (request("Type") == "myrequest") {
                $("#rdoType").css("display", "none");
                $("#divType").css("display", "block");
            }

            if ($("#fld_TTABLETYPE").val() == "发票报销类") {
                document.getElementById("mytable").style.display = "none";
                document.getElementById("mytable1").style.display = "none";
                document.getElementById("DivContract").style.display = "";
                document.getElementById("rdoRemibur").checked = "checked";
                //alert(("#rdoRemibur").html());
                $("#txtfpje").val($("#fld_TFPJE").val());
                $("#lbfpjedx").text($("#fld_TJEDX").val());


            }
            else {
                $("#fld_TTABLETYPE").val("资金支付类");
                //                document.getElementById("mytable").style.display = "";
                document.getElementById("DivContract").style.display = "none";
                changeFKPrice();
            }
        });
        function changeJEDX() {
            var je = $("#txtfpje").val();
            if (isNaN(je)) {
                $("#txtfpje").val("");
                $("#lbfpjedx").text("");
            }
            else {
                $("#lbfpjedx").text(ChangeRMBToCH(je));
                $("#fld_TFPJE").val(je);
                $("#fld_TJEDX").val(ChangeRMBToCH(je));
            }


        }
        function changeFKPrice() {
            var sum = 0;
            $("#mytable").find("tr:gt(0)").each(function (i, Etr) {
                var JE = $(Etr).find("td").eq(9).find("input").val() - 0;
                if (!isNaN(JE)) {
                    sum += JE;
                }
                else {
                    $(Etr).find("td").eq(9).find("input").val("");
                }
            });
            $("#lbje").text(sum);
            //alert(ChangeRMB(sum));
            $("#lbjedx").text(ChangeRMBToCH(sum.toString()));
            $("#fld_TFPJE").val(sum);
            $("#fld_TJEDX").val(ChangeRMBToCH(sum.toString()));
            // alert($("#fld_TFPJE").val());
        }
        //定义多行弹出页面方法
        function Tests(ert) {
            val = window.showModalDialog("../../Modules/Portal/FromEbs.aspx", null, "dialogWidth=850px;dialogHeight=500px");
            if (val) {
                var obj = eval('(' + val + ')');
                if (obj) {
                    $(ert).parent().parent().find("[id*=fld_TCONTRACTNO]").val(obj.htbh);
                    $(ert).parent().parent().find("[id*=fld_TSUPPLIERNAME]").val(obj.gysmc);
                    $(ert).parent().parent().find("[id*=fld_TCONTENTS]").val(obj.note);
                    $(ert).parent().parent().find("[id*=fld_TCONTRACTPRICE]").val(obj.htje);
                    $(ert).parent().parent().find("[id*=fld_TCONTRACTDATA]").val(obj.htsl);
                    $(ert).parent().parent().find("[id*=fld_TSUPPLYDATA]").val(obj.rksl);
                    $(ert).parent().parent().find("[id*=fld_YKPJE]").val(obj.ykpje);
                    $(ert).parent().parent().find("[id*=fld_TPAYMENTPRICE]").val(obj.yfje);
                }
            }
        }

        //校验本次付款金额+已付款金额是否大于合同金额
        function Find(ert) {
            var htje = parseFloat($(ert).parent().parent().find("[id*=fld_TCONTRACTPRICE]").val());
            var yfje = parseFloat($(ert).parent().parent().find("[id*=fld_TPAYMENTPRICE]").val());
            var bcfkje = parseFloat($(ert).parent().parent().find("[id*=fld_TTHISNEEDPRICE]").val());
            if (htje < yfje + bcfkje) {
                alert("已付金额加本次需要金额必须小于等于合同金额");
                $(ert).parent().parent().find("[id*=fld_TTHISNEEDPRICE]").val("");
            }
        }
    </script>
    <script type="text/javascript" language="javascript">
        window.onload = function () {
            document.getElementById("fld_YHKH").onkeyup = function () {
                this.value = this.value.replace(/\s/g, '').replace(/(\d{4})(?=\d)/g, "$1 "); ;
            };
        }; </script>
</head>
<body>
    <form id="form1" runat="server">
    <div class="container">
        <div class="row">
            <ui:userinfo id="UserInfo1" processtitle="工程设备采购支付及发票报销" tablename="PROC_PROJECTPAYREIM"
                tablenamedetail="PROC_PROJECTPAYREIM_DETAIL" runat="server"></ui:userinfo>
        </div>
        <div class="row">
            <table class="table table-condensed table-bordered">
                <tr>
                    <td class="banner" width="17%">
                        表单类别<span class="red">*</span>
                    </td>
                    <td class="td-content">
                        <div id="rdoType">
                            <span onclick="check('rdoMoney')">
                                <asp:RadioButton ID="rdoMoney" runat="server" Checked="true" GroupName="rdos" Text="资金支付类" /></span>
                            <span onclick="check('rdoRemiber')">
                                <asp:RadioButton ID="rdoRemibur" runat="server" GroupName="rdos" Text="发票报销类" /></span>
                        </div>
                        <div id="divType" style="display: none">
                            <asp:TextBox runat="server" ID="fld_TTABLETYPE"></asp:TextBox>
                        </div>
                    </td>
                </tr>
            </table>
            <table id="mytable1" class="table table-condensed table-bordered">
                <tr>
                    <td class="banner" width="17%">
                        资金支付类：
                    </td>
                    <td colspan="9">
                    </td>
                </tr>
                <tr>
                    <td class="td-label">
                        付款金额：<span class="red">*</span>
                    </td>
                    <td class="td-content">
                        <asp:Label ID="lbje" runat="server" Text=""></asp:Label>
                        <div style="display: none">
                            <asp:TextBox runat="server" ID="fld_TFPJE"></asp:TextBox>
                        </div>
                    </td>
                    <td class="td-label">
                        付款金额大写：
                    </td>
                    <td class="td-content">
                        <asp:Label ID="lbjedx" runat="server" Text=""></asp:Label>
                        <div style="display: none">
                            <asp:TextBox runat="server" ID="fld_TJEDX"></asp:TextBox>
                        </div>
                    </td>
                </tr>
                <tr>
                    <td class="td-label">
                        开户行：<span class="red">*</span>
                    </td>
                    <td class="td-content">
                        <asp:TextBox ID="fld_KHH" runat="server" class="validate[required]"></asp:TextBox>
                    </td>
                    <td class="td-label">
                        银行卡号：<span class="red">*</span>
                    </td>
                    <td class="td-content">
                        <asp:TextBox ID="fld_YHKH" runat="server" class="validate[required]"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="td-label">
                        是否在预算内：<span class="red">*</span>
                    </td>
                    <td class="td-content">
                        <asp:DropDownList ID="fld_TISYS" runat="server" CssClass="validate[required]">
                            <asp:ListItem Value="">--请选择--</asp:ListItem>
                            <asp:ListItem Value="是">是</asp:ListItem>
                            <asp:ListItem Value="否">否</asp:ListItem>
                        </asp:DropDownList>
                    </td>
                    <td class="td-label">
                        工程设备销售合同号:<span class="red">*</span>
                    </td>
                    <td class="td-content">
                        <asp:TextBox runat="server" ID="fld_PCNO" CssClass="validate[required]"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="td-label">
                        付款信息：
                    </td>
                    <td class="td-content" colspan="3">
                        <asp:TextBox runat="server" ID="fld_TFKINFO" TextMode="MultiLine" Width="98%" Height="60px"></asp:TextBox>
                    </td>
                </tr>
                <%-- <tr>
                    <td class="td-label">
                        备注：
                    </td>
                    <td class="td-content" colspan="3">
                        <asp:TextBox runat="server" ID="fld_TFKCOMMENTS" Width="98%" Height="60px"></asp:TextBox>
                    </td>
                </tr>--%>
            </table>
            <table id="mytable" class="table table-condensed table-bordered tablerequired">
                <tr>
                    <th>
                        关联
                    </th>
                    <th>
                        合同编号
                    </th>
                    <th>
                        供应商名称
                    </th>
                    <th>
                        内容
                    </th>
                    <th>
                        合同金额
                    </th>
                    <th>
                        合同数量
                    </th>
                    <th>
                        入库数量
                    </th>
                    <th>
                        已开票金额
                    </th>
                    <th>
                        已付金额
                    </th>
                    <th>
                        本次所需要金额
                    </th>
                    <th>
                        预计付款时间
                    </th>
                    <th>
                        <asp:Button ID="Button1" runat="server" Text="增加" CssClass="btn" OnClick="Button1_Click" />
                    </th>
                </tr>
                <asp:Repeater runat="server" ID="fld_detail_PROC_PROJECTPAYREIM_DETAIL" OnItemCommand="fld_PROC_OTHERCAPTITA_PROC_OTHERCAPTITA_DETAIL_ItemCommand">
                    <ItemTemplate>
                        <tr>
                            <td class="td-content">
                                <asp:TextBox ID="fld_FORMID" Text='<%#Eval("FORMID") %>' runat="server" Style="display: none"></asp:TextBox>
                                <asp:Label ID="select" Text="点击查询" onclick="Tests(this)" runat="server" Width="80%"
                                    Style="text-decoration: underline; color: Blue; cursor: pointer;"></asp:Label>
                            </td>
                            <td class="td-content">
                                <asp:TextBox ID="fld_TCONTRACTNO" runat="server" Width="80%" CssClass="validate[required]"
                                    Text='<%#Eval("TCONTRACTNO") %>' onfocus="this.blur()" onpaste="return false" oncopy="return false"></asp:TextBox>
                            </td>
                            <td class="td-content">
                                <asp:TextBox ID="fld_TSUPPLIERNAME" runat="server" Width="80%" CssClass="validate[required]"
                                    Text='<%#Eval("TSUPPLIERNAME") %>' onfocus="this.blur()" onpaste="return false" oncopy="return false"></asp:TextBox>
                            </td>
                            <td class="td-content">
                                <asp:TextBox ID="fld_TCONTENTS" runat="server" Width="80%" Text='<%#Eval("TCONTENTS") %>'></asp:TextBox>
                            </td>
                            <td class="td-content">
                                <asp:TextBox ID="fld_TCONTRACTPRICE" runat="server" Width="80%" Text='<%#Eval("TCONTRACTPRICE") %>'
                                    money="money" class="validate[required]" onfocus="this.blur()" onpaste="return false" oncopy="return false"></asp:TextBox>
                            </td>
                            <td class="td-content">
                                <asp:TextBox ID="fld_TCONTRACTDATA" runat="server" Width="80%" Text='<%#Eval("TCONTRACTDATA") %>'
                                    money="money" class="validate[required]" onfocus="this.blur()" onpaste="return false" oncopy="return false"></asp:TextBox>
                            </td>
                            <td class="td-content">
                                <asp:TextBox ID="fld_TSUPPLYDATA" runat="server" Width="80%" Text='<%#Eval("TSUPPLYDATA") %>'
                                    money="money" class="validate[required]" onfocus="this.blur()" onpaste="return false" oncopy="return false"></asp:TextBox>
                            </td>
                            <td class="td-content">
                                <asp:TextBox ID="fld_YKPJE" runat="server" Width="80%" Text='<%#Eval("YKPJE") %>'
                                    money="money" class="validate[required]" onfocus="this.blur()" onpaste="return false" oncopy="return false"></asp:TextBox>
                            </td>
                            <td class="td-content">
                                <asp:TextBox ID="fld_TPAYMENTPRICE" money="money" runat="server" Width="90%" Text='<%#Eval("TPAYMENTPRICE") %>'
                                    class="validate[required]" onfocus="this.blur()" onpaste="return false" oncopy="return false"></asp:TextBox>
                            </td>
                            <td class="td-content">
                                <asp:TextBox ID="fld_TTHISNEEDPRICE" onblur="Find(this)" onkeyup="changeFKPrice();" runat="server" Width="80%"
                                    Text='<%#Eval("TTHISNEEDPRICE") %>' money="money" class="validate[required]"></asp:TextBox>
                            </td>
                            <td class="td-content">
                                <asp:TextBox ID="fld_TADVANCEDATE" runat="server" Width="80%" OnClick="WdatePicker({dateFmt:'yyyy-MM-dd'})"
                                    CssClass="validate[required] Wdate" Text='<%#Eval("TADVANCEDATE") %>'></asp:TextBox>
                            </td>
                            <td style="background-color: #f5f5f5;" align="center" width="6%">
                                <asp:Button ID="btnDelete" runat="server" Text="删除" CssClass="btn" CommandName="del"
                                    ClientIDMode="Static" OnClientClick="deletetS(this);return confirm('确认删除？')" />
                            </td>
                        </tr>
                    </ItemTemplate>
                </asp:Repeater>
            </table>
            <table id="DivContract" style="display: block;" class="table table-condensed table-bordered">
                <tr>
                    <td class="banner" colspan="4">
                        发票报销类
                    </td>
                </tr>
                <tr>
                    <td class="td-label">
                        所属公司：<span class="red">*</span>
                    </td>
                    <td class="td-content" colspan="3">
                        <asp:TextBox ID="fld_TSSGS" runat="server" CssClass="validate[required]"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="td-label">
                        发票金额：<span class="red">*</span>
                    </td>
                    <td class="td-content">
                        <%--onpropertychange="changeJEDX()"--%>
                        <asp:TextBox ID="txtfpje" runat="server" Text="" onblur="changeJEDX()" money="money"
                            class="validate[required]"></asp:TextBox>
                    </td>
                    <td class="td-label">
                        发票金额大写：
                    </td>
                    <td class="td-content">
                        <asp:Label ID="lbfpjedx" runat="server" Text=""></asp:Label>
                    </td>
                </tr>
                <tr>
                    <td class="td-label">
                        发票号：<span class="red">*</span>
                    </td>
                    <td class="td-content" colspan="3">
                        <asp:TextBox ID="fld_TINVOCIENO" runat="server" CssClass="validate[required]"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="td-label">
                        发票信息：<span class="red">*</span>
                    </td>
                    <td class="td-content" colspan="3">
                        <asp:TextBox ID="fld_TINVOICEINFO" Width="98%" Height="60px" runat="server" CssClass="validate[required]"></asp:TextBox>
                    </td>
                </tr>
                <%-- <tr>
                    <td class="td-label">
                        备注：
                    </td>
                    <td class="td-content" colspan="3">
                        <asp:TextBox ID="fld_TFPCOMMENTS" runat="server" Width="98%" Height="60px"></asp:TextBox>
                    </td>
                </tr>--%>
            </table>
        </div>
        <div class="row">
            <attach:attachments id="Attachments1" runat="server"></attach:attachments>
        </div>
        <div class="row">
            <ah:approvalhistory id="ApprovalHistory1" runat="server" showaction="false"></ah:approvalhistory>
        </div>
        <div class="row">
        </div>
    </div>
    <btn:buttonlist id="ButtonList1" runat="server"></btn:buttonlist>
    <div style="display: none;">
    </div>
    </form>
</body>
</html>
